package br.ucb.managedbean;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import br.ucb.bean.Curso;
import br.ucb.bean.NovaAquisicao;
import br.ucb.dao.CursoDAO;
import br.ucb.util.SimpleEntityManager;

@ManagedBean
@SessionScoped
public class NovaAquisicaoManagedBean implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 9074212768370230674L;
	private NovaAquisicao aquisicao;
	private List<Curso> cursos;
	private SimpleEntityManager manager;
	
	public NovaAquisicaoManagedBean() {
		this.aquisicao = new NovaAquisicao();
	}
	
	public void readyManagerAndDao() {
		this.manager = new SimpleEntityManager("sacop");
		this.manager.beginTransaction();
	}
	
	public void gerarNotificacao(){
		
	}

	public List<Curso> getCursos() {
		readyManagerAndDao();
		setCursos(new CursoDAO(this.manager.getEntityManager()).listar());
		manager.close();
		return cursos;
	}

	public void setCursos(List<Curso> cursos) {
		this.cursos = cursos;
	}

	public NovaAquisicao getAquisicao() {
		return aquisicao;
	}

	public void setAquisicao(NovaAquisicao aquisicao) {
		this.aquisicao = aquisicao;
	}

}
